/**
 * Created by Administrator on 2017/4/6 0006.
 */
var React = require('react');

var ajax = require('../tools/ajax');

module.exports = React.createClass({
    getInitialState: function () {
        return {
            orderGoods:null,
        }
    },
    componentDidMount: function () {
        this.getOrderGoods();
    },
    getOrderGoods(){
        var p =this;
        var order_id = p.props.id;
        ajax("POST","getOrderGoods",{order_id:order_id},function(dt){
            if(dt&&dt.success){
                var objs = dt.data;
                p.setState({orderGoods:objs});
            }
        });
    },
    render: function () {
        var p=this;
        var orderGoods = p.state.orderGoods;
        if(orderGoods) {
            var orderGoodList = orderGoods.map(function (obj, index) {
                if (obj.goods_img) {
                    var goods_img = obj.goods_img.split(",")[0];
                }
                return (
                    <div key={index} className={index?"pro border":"pro"}>
                        <img src={goods_img}/>
                        <div className="introduce">
                            <div className="shopname">{obj.shopname ? obj.shopname : "跨乐购平台"}</div>
                            <p className="goodsName">{obj.goods_name}</p>
                        </div>
                        <div className="goodsNumber">X{obj.goods_number}</div>
                    </div>
                )
            });
        }
        return(
            <div>
                {orderGoodList}
            </div>
        )
    }
});

